package utils;

public class IResult {
	private int code;
	private String msg;
	private Object data;
	private int count;
	
	
	

	
	
	
	
	
	
	
	
	public static IResult ok(Object data) {
		IResult result = new IResult();
		result.setCode(0);
		result.setData(data);
		return result;
	}
	
	public static IResult ok(int count,Object data) {
		IResult result = new IResult();
		result.setCode(0);
		result.setCount(count);
		result.setData(data);
		return result;
	}
	
	public static IResult ok() {
		IResult result = new IResult();
		result.setCode(0);
		return result;
	}
	
	public static IResult fail(String msg) {
		return fail(-1,msg);
	}
	
	public static IResult fail(int code,String msg) {
		IResult result = new IResult();
		result.setCode(code);
		result.setMsg(msg);
		
		return result;
	}
	
	public static IResult success(String msg) {
        IResult result = new IResult();
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }

    public static IResult error(String msg) {
        IResult result = new IResult();
        result.setCode(-1);
        result.setMsg(msg);
        return result;
    }
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
}
